//1.箭头函数里面的this指向的是外层的对象作用域
//2.对象字面量{}没有作用域
//三.对象
//------------------------1.字面量(用的最多)---------------------------
let user1 ={
    name:"zs",
    age:24,
    walk: function (){
        console.log(this.name+"1111")
        let addOil=()=>{
            console.log(this)
            console.log(this+"加油----")
        }
        addOil()
    },
    car1:{
        brand:"benchi",
        addOil:()=>{

        }
    }
}
let name="ww"
let age=24
//es6新特性：对象里面的function可以省略,属性键和值一样,可省略(有前提：定义了变量)
let user2 ={
    name,
    age,
    walk(){
        console.log(this.name+"2222")
    }
}
user1.walk()
user2.walk()
//------------------------2.new Object()---------------------------
const car = new Object()
car.brand = "xiaomi"
car.drive=function (){
    console.log(this.brand+"开车----")
}
car.addOil=()=>{
    console.log(this.brand+"加油----")
}
// car.drive()
// car.addOil()

user1.car = car

//------------------------3.构造函数---------------------------
function Person(name,sge){
    this.name = name
    this.age = age
    this.walk = function () {
        console.log(this.name+"正在走路！！！！")
    }
}
const  p1 =new Person("James",40)
p1.walk()
//------------------------4.类class(es6的新特性)---------------------------
class Person1{
    constructor(name,age) {
        this.name =name
        this.age =age
    }
    walk(){
        console.log(this.name+"正在走路！！")
    }
}
const  p2 = new Person1("Wade",38)
p2.walk()













